set the visible of card field 1 to not the visible of card field 1
if the visible of card field 1 is true then
set the name of me to "Hide Pascal Source"
else set the name of me to "Show Pascal Source"
end mouseUp
-- part 3 (button)
-- low flags: 00
-- high flags: A003
-- rect: left=80 top=300 right=322 bottom=180
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Try It
----- HyperTalk script -----
on mouseUp
ask "What is your birthday?"
if it is not empty then
put convertdate(it) into birthday
if word 1 of birthday is not "Error" then
get the date
put convertdate(it) into today
subtract birthday from today
divide today by 60
divide today by 60
divide today by 24
answer "Today is your" && today+1 & "th day. Congratulations!"
else
answer "That doesn't make sense as a date."
end if
end if
end mouseUp
-- part contents for background part 16
----- text -----
CONVERTDATE XFCN version 1.0.1
Kevin Calhoun
ConvertDate performs a function identical to that of the HyperTalk "convert" command--it converts a date expressed in one of the standard HyperCard formats into another expression, in a specified format, for the same date. (The standard formats for dates are defined on page 99 of the HyperCard Script Language Guide.)
The advantage of using ConvertDate rather than the HyperTalk command "convert" is that ConvertDate can recognize dates far beyond the range of those that HyperCard is currently capable of handling properly: from January 1, 1904 to February 6, 2040. ConvertDate relies on routines in the new version of the Script Manager that handle all dates within about 35 thousand years of January 1, 1904; however, there are other features of these Script Manager routines that limit the range more severely. When converting dates in the dateItems format or the seconds format, ConvertDate will properly convert all dates falling between January 1 of the year 1 and December 31, 9999. When converting dates in the long date, short date, or abbreviated date formats, ConvertDate works properly for dates from January 1, 1000 to December 31, 9999*.
ConvertDate recognizes the format of the input expression by itself, whether the format is seconds, dateItems, long date, short date, or abbreviated date.
WHAT IT'S GOOD FOR
ConvertDate is intended chiefly for those users who need to sort the cards of a stack by date. Use ConvertDate to convert the dates to seconds format; then use the HyperTalk command "sort" to sort the stack.
ConvertDate is also useful for determining which day of the week it was when you were born, how many days have passed since July 4, 1776, and all that sort of thing.
INVOKING CONVERTDATE
get ConvertDate(inputExpression,<outputFormat>)
result: a date in the format specified
The second parameter can be any of the standard date formats as defined on page 99 of the HyperCard Script Language Guide. If there is no second parameter, or if it is something other than one of the standard formats, ConvertDate defaults to seconds.
EXAMPLES
get ConvertDate(card field 2,"abbr date")
get ConvertDate("Wednesday, March 15, 1989","dateItems")
get ConvertDate("1959,5,14,0,0,0,0","long date") -- note that when using dateItems
format, it isn't necessary to enter the correct day of week
* It is not yet clear to me whether the Script Manager routines that ConvertDate relies on take into account, in localized versions of the System Software, any or all of the historical twiddlings of the official calendar that apply or have applied to a given geographical region. In other words, if you're attempting to calculate the interest owed on a longstanding loan made earlier than 1914 by your ancestors to the ancestors of a debtor, I recommend hiring a specialist.
Here is the reason that January 1, 1000 is the earliest date that can be converted successfully when expressed in long date, short date, or abbreviated date format: the Script Manager routine String2Date adds 1900 to years earlier than 100, so that 1/1/75 means January 1, 1975, and 1000 to years earlier than 1000, so that 1/1/975 means the same as 1/1/75. When using ConvertDate with an input date in dateItems format or seconds format, the XFCN doesn't call String2Date to interpret the input; therefore if you want to handle dates between January 1, 1, and January 1, 1000, you can ensure correctness by representing dates in dateItems format or seconds format and converting them to your preferred format for display purposes. The range of the output year, 1 to 9999, is imposed by the Script Manager routine LongSecs2Date.
REVISION HISTORY
March 17, 1989 -- 1.0 release.
March 31, 1989 -- 1.0.1. Fixed problem with dates input in short date format. Input expression, if a container, should no long be quoted.
-- part contents for card part 1
----- text -----
UNIT ConvertDateUnit;
{ ConvertDate XFCN ©1989 by the Trustees of Dartmouth College }